package com.example.meitu.api.schedule;

import com.example.meitu.api.common.DateUtils;
import com.example.meitu.api.service.ArticleStatisticService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@Component
@Slf4j
public class BuildStatisticSchedule {

    @Resource
    private ArticleStatisticService articleStatisticService;

    /**
     * 每天11点生成“日统计表”的数据
     */
    @Scheduled(cron = "0 0 11 * * ? ")
    public void buildStatistic(){
      List<Integer> brandIds = new ArrayList<>();
      Integer start = DateUtils.lastDayStart();
      Integer end = DateUtils.lastDayEnd();
      log.info("开始定时任务，buildStatistic");
      articleStatisticService.calcBrandMediaStatistic(brandIds, null,start,end);
      log.info("结束定时任务，buildStatistic");
    }

}
